/*******************************************************************************
 * Level Master 2000
 * Copyright (C) 2010 Christian Herzog
 * For more information see http://code.google.com/p/levelmaster2000/
 *
 * This file is licensed under the terms of the MIT license, see
 * http://www.opensource.org/licenses/mit-license.php for further information.
 ******************************************************************************/

#ifndef LEVEL_MANAGER_H
#define LEVEL_MANAGER_H

#include "LevelDescription.h"

#include <QDockWidget>
#include <QString>
#include <QList>
#include <QTreeWidget>

class LevelManager : public QDockWidget
{
    Q_OBJECT

public:
    LevelManager( QWidget *parent );
    ~LevelManager();

    void setWorkspaceDir( QString dir );
    int loadLevelDescriptions();

private:
    void init();
    void buildLevelDescriptionTree();

public slots:
    void setWorkspace();
    void show();
    void saveCurrentLevel();
    void onSaveLevel( QString levelState );

private slots:
    void loadSelectedLevel();

signals:
    void loadLevel( int index, QString name );
    void requestSaveCurrentLevel( int index, QString name );
    void workspaceChanged( QString newWorkspace );

private:
    QList<LevelDescription*> levelDescriptions;
    LevelDescription* currentLevel;
    QString workspaceDir;
    QTreeWidget *levelTree;
};

#endif
